package com.faradel.pharmapp.service;

import java.util.List;

import javax.annotation.Resource;

import org.faradel.pharmapp.entities.Provider;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.faradel.pharmapp.dao.ProviderDAO;

@Service("providerServiceImpl")
public class ProviderServiceImpl implements ProviderServiceInterface
{
    @Resource
    ProviderDAO providerDaoImpl;

    @Override
    @Transactional(readOnly = false)
    public void addProvider(Provider patient)
    {
        providerDaoImpl.save(patient);
    }

    @Override
    @Transactional(readOnly = false)
    public void updateProvider(Provider patient)
    {
        providerDaoImpl.update(patient);
    }

    @Override
    @Transactional(readOnly = false)
    public void deleteProvider(Provider patient)
    {
        providerDaoImpl.delete(patient);
    }

    @Override
    @Transactional(readOnly = true)
    public Provider getProviderById(int id)
    {
        return providerDaoImpl.get(id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Provider> getAllProvider()
    {
        return (List<Provider>) providerDaoImpl.selectAll();
    }

}
